#pragma once

#include "Mesh.h"
#include <vector>


struct Vertex
{
	vec3 pos;
	vec3 normal;
	vec2 uv;

	static const D3D11_INPUT_ELEMENT_DESC layout[]; 
};

class CUnitMesh : public CAiMesh
{
public:
	CUnitMesh(ID3D11Device* pDevice);
	~CUnitMesh();

	void Render(float* Porj, float* View, float* model, float* world);
protected:
	bool InitFromScene(const aiScene* pScene, const std::string& Filename);
	void Clear();
	bool InitD3DObjects();
	void InitMesh(unsigned int Index, const aiMesh* paiMesh);
	void InitMetrials( const aiScene* pScene, const std::string& Filename );
#define INVALID_MATERIAL 0xFFFFFFFF

	struct MeshEntry {
		UINT NumIndices;
		UINT StartIndexLocation;
		UINT BaseVertex;
	};

	std::vector<ID3D11Texture2D*> m_Textures;
	std::vector<MeshEntry> m_Entries;
	std::vector<Vertex> m_Vertices;
	std::vector<UINT> m_Indices;

	ID3DX11Effect* m_pEffect;
	ID3D11Buffer* m_pIndexBuffer;
	UINT m_Stride;
	ID3D11ShaderResourceView* m_pSRV;
};